//
//            readScp1000LQ01.pde
// Read the Barometric Pressure and Temperature values from SCP1000 sensor
//
// based on sample code from Arduino forum
// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236443720/8
//

#include <LiquidCrystal.h>
#include <SCP1000.h>

// Specify slave select pin for SCP1000 device
#define SelectPin 10

#define CELCIUS_SIGN 0
#define ANALOG0 14


SCP1000 scp1000(SelectPin);
// LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) 
LiquidCrystal lcd(8, 6, 7, 5, 4, 3, 2);

byte CEL[8]={
B11000,
B11000,
B00110,
B01001,
B01000,
B01001,
B00110,
};


void setup()
{
  
   // Serial.begin(9600); // Open serial connection to report values to host
   // Serial.println("Starting up");
   
   lcd.begin(16,2);
   lcd.print("Starting up");
   lcd.createChar(CELCIUS_SIGN,CEL);
  
   scp1000.init();
   
   pinMode(ANALOG0, OUTPUT);
   
   
}

void loop()
{
  int tempI;
  float tempF;
  int hpaI;
  float hpaF;

  digitalWrite(ANALOG0,HIGH);
  scp1000.readSensor();
  
  lcd.clear();
  
  lcd.setCursor(0,0);
  hpaI= scp1000.BaroP * 10 ;
  hpaF=hpaI / 10.0;
  lcd.print(hpaF);
  lcd.setCursor(6,0);
  lcd.print("hPa ");
  tempI = scp1000.TempC * 10;
  tempF = tempI / 10.0;
  lcd.print(tempF);
  lcd.setCursor(14,0);
  lcd.write(CELCIUS_SIGN);

  digitalWrite(ANALOG0,LOW);
  
  // Serial.print("Temprature (C/F): ");
  // Serial.print(scp1000.TempC);
  // Serial.print(" / ");
  // Serial.println( (1.8*scp1000.TempC + 32) );
  // Serial.print("Pressure (hPa): ");
  // Serial.println(scp1000.BaroP);
  // Serial.println("---------------------------------");

  delay(6000);
}
  

